package newcoder.lx_字符串去重和重排;

import java.util.*;

/**
 * @Author Mr.wang
 * @Description
 * @Date 2020-04-12
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < line.length(); i++) {
                String ch = line.charAt(i) + "";
                if (map.containsKey(ch)) {
                    Integer integer = map.get(ch);
                    map.remove(ch);
                    map.put(ch, integer + 1);
                } else {
                    map.put(ch, 1);
                }
            }

            // Map 的遍历
            List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
            // 按照出现顺序从大到小
            list.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
            for (Map.Entry<String, Integer> o : list) {
                System.out.print(o.getKey().concat(":").concat(String.valueOf(o.getValue())).concat(";"));
            }
        }
    }
}
